<template>
    <a-spin :spinning="confirmLoading">
      <!-- 主表单区域 -->
      <a-form :form="form">
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-item label="所属单位" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-select-category v-decorator="['assetFixedCategoryId']" :disabled="true"></j-select-category>
            </a-form-item>
          </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="所属单位" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-dict-select-tag  v-decorator="['subordinateUnits', {}]" :triggerChange="true" placeholder="请选择所属单位"-->
<!--                                  dictCode="subordinate_units"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="物资名称">
              <a-input placeholder="请输入物资名称" v-decorator="['name', {}]" />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="规格型号">
              <a-input placeholder="请输入规格型号" v-decorator="['specifications', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="单位">
              <a-input placeholder="请输入单位" v-decorator="['unit', {}]" :disabled="true" />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="数量">
              <a-input-number placeholder="请输入数量" v-decorator="['amount', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="单价">
              <a-input-number v-decorator="[ 'price', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="合价">
              <a-input-number v-decorator="[ 'total', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="采购部门">
              <a-input placeholder="请输入采购部门" v-decorator="['purchasingDepartment', {}]" />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="采购日期">
              <a-date-picker showTime format="YYYY-MM-DD HH:mm:ss" v-decorator="[ 'purchaseDate', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="图片">
              <!--            <a-input placeholder="请输入图片" v-decorator="['image', {}]" />-->
              <!--            <j-image-upload  v-decorator="['image', {}]"></j-image-upload>-->
              <j-image-upload text="上传"v-decorator="['image', {}]" :isMultiple="true"  :number="6"></j-image-upload>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="材质说明">
              <a-input placeholder="请输入材质说明" v-decorator="['description', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="楼层">
              <a-input placeholder="请输入楼层" v-decorator="['floor', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="尺寸">
              <a-input v-decorator="[ 'assetSize', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="款式">
              <a-input placeholder="请输入款式" v-decorator="['assetStyle', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="技术参数">
              <a-input placeholder="请输入技术参数" v-decorator="['technicalParameters', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="品牌">
              <a-input placeholder="请输入品牌" v-decorator="['brand', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="备注">
              <a-input placeholder="请输入备注" v-decorator="['remark', {}]" :disabled="true"/>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>

    </a-spin>
</template>

<script>

import pick from 'lodash.pick'
import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
import JDate from '@/components/jeecg/JDate'
import JUpload from '@/components/jeecg/JUpload'
import JImageUpload from '@/components/jeecg/JImageUpload'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
import JTreeSelect from '@/components/jeecg/JTreeSelect'
import JCompanySelectTag from '@comp/jeecg/JCompanySelectTag'
import JSelectCategory from '../../../components/jeecgbiz/JSelectCategory'
import { IS_GROUP } from '@/store/mutation-types'
import moment from 'moment'

export default {
  name: 'AssetInfo',
  mixins: [JEditableTableMixin],
  components: {
    JDate,
    JUpload,
    JImageUpload,
    JSearchSelectTag,
    JTreeSelect,
    JCompanySelectTag,
    JDictSelectTag,
    JSelectCategory
  },
  data () {
    return {
      // form: this.$form.createForm(this),
      //腾讯地图
      tencentMapUrl: '',
      images: '',
      container: Math.random().toString(36).substr(2),
      latlng: {
        lng: 106.600782,
        lat: 29.718219
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      labelCol2: {
        xs: { span: 24 },
        sm: { span: 3 }
      },
      wrapperCol2: {
        xs: { span: 24 },
        sm: { span: 20 }
      },
      // 新增时子表默认添加几行空数据
      addDefaultRowNum: 0,
      disableSubmit: false,
      isDisposal: false,
      validatorRules: {
      },
      url: {
        add: '/zcgl/assetFixed/add',
        edit: '/zcgl/assetFixed/edit'
      }
    }
  },
  methods: {
    /** 调用完edit()方法之后会自动调用此方法 */
    showModal (r) {
      this.model = Object.assign({}, r)
      console.log(r)
      let isGroup = sessionStorage.getItem(IS_GROUP)
      if (isGroup == 1) {
        let companyName = {
          rules: [{
            required: true, message: '请选择所属公司!'
          }]
        }
        this.validatorRules.companyId = companyName
      }

      this.$nextTick(() => {
        let keys = Object.keys(this.form.formItems)
        this.form.setFieldsValue(pick(this.model, keys))
        this.form.setFieldsValue({ purchaseDate: this.model.purchaseDate ? moment(this.model.purchaseDate) : null })
      })
    },
  }
}
</script>

<style scoped>
</style>